home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / xpaint-2.1.1 / PaintP.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  5KB  |  173 lines

  1. #ifndef _PaintP_h
  2. #define _PaintP_h
  3.  
  4. /* +-------------------------------------------------------------------+ */
  5. /* | Copyright 1992, 1993, David Koblas (koblas@netcom.com)            | */
  6. /* |                                                                   | */
  7. /* | Permission to use, copy, modify, and to distribute this software  | */
  8. /* | and its documentation for any purpose is hereby granted without   | */
  9. /* | fee, provided that the above copyright notice appear in all       | */
  10. /* | copies and that both that copyright notice and this permission    | */
  11. /* | notice appear in supporting documentation.  There is no           | */
  12. /* | representations about the suitability of this software for        | */
  13. /* | any purpose.  this software is provided "as is" without express   | */
  14. /* | or implied warranty.                                              | */
  15. /* |                                                                   | */
  16. /* +-------------------------------------------------------------------+ */
  17.  
  18. #include "Paint.h"
  19. /* include superclass private header file */
  20. #include <X11/CoreP.h>
  21. #include <X11/CompositeP.h>
  22. #include <X11/Xutil.h>
  23.  
  24. /* define unique representation types not found in <X11/StringDefs.h> */
  25.  
  26. #define XtRPaintResource "PaintResource"
  27.  
  28. typedef struct {
  29.     int        empty;
  30. } PaintClassPart;
  31.  
  32. typedef struct _PaintClassRec {
  33.     CoreClassPart    core_class;
  34.     CompositeClassPart    composite_class;
  35.     PaintClassPart    paint_class;
  36. } PaintClassRec;
  37.  
  38. extern PaintClassRec paintClassRec;
  39.  
  40. typedef struct s_undoStack {
  41.     XRectangle        box;
  42.     Pixmap            pixmap;
  43.     Boolean            valid;
  44.     struct s_undoStack    *next, *prev;
  45. } UndoStack;
  46.  
  47. typedef struct {
  48.     int        drawWidth, drawHeight;
  49.     int        fillRule, lineFillRule;
  50.     GC        gc, igc, fgc, sgc;
  51.     Pixmap        sourcePixmap;
  52.     Pixmap        pattern, linePattern;
  53.     int        lineWidth;
  54.     XFontStruct    *fontInfo;
  55.     Pixel        foreground, background, lineForeground;
  56.     int        undoSize;
  57.     int        readOnly;
  58.  
  59.     /*
  60.     **  The undo system
  61.     */
  62.     Pixmap        base;
  63.     UndoStack    *undo, *head, *tail;
  64.     Boolean        dirty;
  65.  
  66.     Boolean        snapOn, grid;
  67.     int        snap;
  68.     void        *eventList;
  69.     XtCallbackList    fatcalls;
  70.     XtCallbackList    sizecalls;
  71.     XtCallbackList    regionCalls;
  72.     int        zoomX, zoomY;
  73.     int        zoom;
  74.     GC        tgc;    /* scratch GC, for stuffing clip masks into */
  75.     GC        mgc;    /* region mask GC, 1 bit deep */
  76.     GC        xgc;    /* XOR (invert) GC */
  77.     Widget        paint;
  78.     Boolean        paintGone;
  79.     int        paintChildrenSize;
  80.     Widget        *paintChildren;
  81.     Pixel        linePixel;
  82.     Boolean        compress;
  83.     Cursor        cursor;
  84.  
  85.     /*
  86.     **  Region info
  87.     */
  88.     struct {
  89.         Boolean            inited;
  90.         Widget            child;
  91.         Widget            grip[9];
  92.         Position        offX, offY;
  93.         Position        baseX, baseY;
  94.         XRectangle        rect, orig;
  95.         GC            fg_gc, bg_gc;
  96.  
  97.         Boolean            isTracking, isDrawn, isRotate;
  98.         float            lastAngle;
  99.         int            fixedPoint;
  100.         float            lineDelta[4], lineBase[2];
  101.         float            startScaleX, startScaleY;
  102.  
  103.         Pixmap            source, mask, notMask;
  104.         XImage            *sourceImg, *maskImg, *notMaskImg;
  105.  
  106.         Boolean            isAttached, isVisible, needResize;
  107.         Pixmap            undoPixmap;
  108.         /*
  109.         **  The scale{X,Y} are combined with the rotMat
  110.         **    to produce mat.
  111.         */
  112.         float            centerX, centerY;
  113.         float            scaleX, scaleY;
  114.         pwMatrix        rotMat, mat;
  115.  
  116.         int            curZoom;
  117.         pwRegionDoneProc    *proc;
  118.     } region;
  119.  
  120.     Boolean    invalidateRegion;
  121.     Region    imageRegion;
  122.     XImage    *image;
  123.  
  124.     Position    downX, downY;    /* Last button down X & Y pos */
  125.  
  126.     /*
  127.     **  Taken from our parent shell
  128.     */
  129.     Visual    *visual;
  130. } PaintPart;
  131.  
  132. #define PwPixmap(w)    ((w)->paint.active->pixmap)
  133.  
  134. typedef struct _PaintRec {
  135.     CorePart        core;
  136.     CompositePart    composite;
  137.     PaintPart        paint;
  138. } PaintRec;
  139.  
  140. #define _GET_PIXMAP(pw) \
  141.         ((pw)->paint.undo ? (pw)->paint.undo->pixmap : (pw)->paint.base)
  142. #define GET_PIXMAP(pw) (pw->paint.paint ? \
  143.         _GET_PIXMAP((PaintWidget)pw->paint.paint) : _GET_PIXMAP(pw))
  144.  
  145. #define _GET_ZOOM(pw)    pw->paint.zoom
  146. #define GET_ZOOM(pw) ((pw->paint.zoom == PwZoomParent) ? \
  147.         _GET_ZOOM(((PaintWidget)pw->paint.paint)) : _GET_ZOOM(pw))
  148.  
  149. #define GET_MGC(pw, msk)    ((pw)->paint.mgc == None ? \
  150.     (pw->paint.mgc = XCreateGC(XtDisplay(pw), msk, 0, 0)) : pw->paint.mgc)
  151.  
  152. void    pwRegionZoomPosChanged(PaintWidget);
  153. void    _PwZoomDraw(PaintWidget, Widget, GC, XImage*, XImage*, 
  154.             Boolean, int, int, int, XRectangle *);
  155.  
  156. /*
  157. **  Try to optimize XGetPixel and XPutPixel
  158. **
  159. */
  160. #define ZINDEX8(x, y, img)  ((y) * img->bytes_per_line) + (x)
  161. #define xxGetPixel(img, x, y)                     \
  162.         ((img->bits_per_pixel == 8) ?            \
  163.             img->data[ZINDEX8(x, y, img)] :        \
  164.             XGetPixel(img, x, y))
  165. #define xxPutPixel(img, x, y, p) do {                \
  166.         if (img->bits_per_pixel == 8)            \
  167.             img->data[ZINDEX8(x, y, img)] = p;    \
  168.         else                        \
  169.             XPutPixel(img, x, y, p);        \
  170.     } while (0)
  171.  
  172. #endif /* _PaintP_h */
  173.